UNPKG

1.47 kBJavaScriptView Raw
1'use strict';
2
3var Should = require('should');
4var app = require('../examples/extensions/app');
5
6describe('Extensions', function() {
7 describe('app.extension(id: string)', function() {
8 it('should exists', function() {
9 app.extension.should.be.a.Function();
10 app.ext.should.be.a.Function();
11 });
12 });
13
14 describe('app.extension(name: String)', function() {
15 it('should throw exception', function() {
16 (function() {
17 app.extension('c');
18 }).should.throw();
19 });
20
21 it('should return result', function() {
22 app.extension('a').should.have.property('value', 'a');
23 app.ext('a/b').should.have.property('value', 'a/b');
24 app.extension('./a/b/c').should.have.property('value', 'a/b/c');
25 app.ext('./b').should.have.property('value', 'b');
26
27 Should.equal(app.extension('a'), app.ext('a'));
28 });
29
30 it('should show full error in extension', function() {
31 var non_exists_extension_name = 'non-exists';
32 try {
33 app.extension(non_exists_extension_name);
34 } catch(error) {
35 error.message.should.containEql(non_exists_extension_name);
36 }
37
38 try {
39 app.extension('with-error');
40 } catch(error) {
41 Should.equal(error.message, 'Expected error message');
42 }
43 });
44 });
45});